<?php
namespace Modules\Auth\Services;


use Illuminate\Support\Facades\Hash;

use Modules\Auth\API\APIHelper;
use Modules\Auth\Entities\Admin;
use Modules\Common\Services\BaseService;

class AdminService extends BaseService
{
    private $helper;
    private $options;
    public function __construct(APIHelper $helper)
    {
        $this->helper = $helper;
        $this->options = $this->helper->getClientConfig('admin');
    }
    public function login(array $data){
        $user = new Admin();
        $user=$user->findForPassport($data['username']);
        if ( $user ) {
            if (Hash::check($data['password'], $user->password)) {
                return  $this->helper->Login($data['username'],$data['password'],$this->options);
            }
        }
        return false;

    }
}
